/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sys.service;

import com.thinkgem.jeesite.common.service.TreeService;
import com.thinkgem.jeesite.modules.sys.dao.ClassifyDao;
import com.thinkgem.jeesite.modules.sys.entity.Classify;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 机构Service
 * @author ThinkGem
 * @version 2014-05-16
 */
@Service
@Transactional(readOnly = true)
public class ClassifyService extends TreeService<ClassifyDao, Classify> {

	public List<Classify> findAll(){
		return this.findList(true);
	}

	public List<Classify> findList(Boolean isAll){
		Classify classify = new Classify();
		return dao.findList(classify);
	}
	
	@Transactional(readOnly = true)
	public List<Classify> findList(Classify classify){
		if(classify != null){
			classify.setParentIds(classify.getParentIds()+"%");
			return dao.findByParentIdsLike(classify);
		}
		return  new ArrayList<Classify>();
	}
	
	@Transactional(readOnly = false)
	public void save(Classify classify) {
		super.save(classify);
		
	}
	
	@Transactional(readOnly = false)
	public void delete(Classify classify) {
		super.delete(classify);
	}
	
}
